package com.jandan.ui.client;

import com.gwtext.client.core.Function;
import com.gwtext.client.widgets.Panel;
import com.gwtext.client.widgets.Tool;
import com.gwtext.client.widgets.layout.AccordionLayout;
import com.jandan.ui.client.util.ClientUtil;

public class LeftPanel extends Panel {
	private ILessonOperator lessonOperator;
	private MyLessonPanel myLessonPanel;
	private StrangeWordPanel strangeWordPanel;
	private ExtendedInfoPanel extendedInfoPanel;
	
	public LeftPanel(ILessonOperator lessonOperator){
		this.lessonOperator = lessonOperator;
		
		this.createComponent();
	}
	
	public LeftPanel(){
		this.createComponent();
	}
	
	private void createComponent(){
		this.setLayout(new AccordionLayout(true));
		this.setAutoScroll(true);
		this.myLessonPanel = new MyLessonPanel(this.lessonOperator);
		
		myLessonPanel.addTool(new Tool(Tool.GEAR, new Function() {   
            public void execute() {   
				LessonWindow window = new LessonWindow(lessonOperator);//ClientUtil.COMMON_LESSON);
				window.show();
            }   
        }, "新建课程"));   
		
		myLessonPanel.addTool(new Tool(Tool.SEARCH, new Function() {   
            public void execute() {   
				ChooseLessonWindow chooseLessonWindow = new ChooseLessonWindow(lessonOperator,ClientUtil.DELETE_LESSON);
				chooseLessonWindow.show();
            }   
        }, "删除课程"));   
  
        this.add(myLessonPanel);   

        
        this.strangeWordPanel = new StrangeWordPanel(lessonOperator);
        this.add(this.strangeWordPanel);   
  
        this.extendedInfoPanel = new ExtendedInfoPanel(lessonOperator);
        this.add(extendedInfoPanel);
	}
	
	public MyLessonPanel getMyLessonPanel(){
		return this.myLessonPanel;
	}
	
	public StrangeWordPanel getStrangeWordPanel(){
		return this.strangeWordPanel;
	}
	
	public ExtendedInfoPanel getExtendedInfoPanel(){
		return this.extendedInfoPanel;
	}
}
